#!/usr/local/bin/ruby
# Copyright (C) 2003-2010 Wang Pengcheng <wpc0000@gmail.com>
# , released under the MIT license
# You may obtain a template of the MIT License at
# http://www.opensource.org/licenses/mit-license.php
$KCODE = 'utf8'

file=ARGV[0]
data = File.read(file)

packet_size = 0
delay_time = 0

data.split("\n").each do |line|
  if line=~/.+\((\d+)\).+(\d+\.\d+)/
    sdata = Regexp.last_match
    size = sdata[1].to_i
    delay = sdata[2].to_f
    packet_size+=size
    delay_time+=delay*size
  end
end
p delay_time/packet_size


